package com.icebergteam.warfacewidget.rank.data;

import com.icebergteam.warfacewidget.AppManager;
import com.icebergteam.warfacewidget.R;
import com.icebergteam.warfacewidget.core.ListViewItem;

import android.os.Parcel;
import android.os.Parcelable;

public class Top100Item extends ListViewItem  {

	public static final int ASSAULT_CLASS_TYPE = 1;
	public static final int MEDIC_CLASS_TYPE = 2;
	public static final int ENGINEER_CLASS_TYPE = 3;
	public static final int SNIPER_CLASS_TYPE = 4;
	
	
	static public final String className = Top100Item.class.getCanonicalName();
	private int pos;
	private String nickname;
	private int progress;
	private int classtime;
	private String clanname;
	private String imgSrc;

	public Top100Item() {
		super();
		setPos(1);
		setNickname("test");
		setProgress(90);
		setClasstime(ASSAULT_CLASS_TYPE);
		setImgSrc("imgSrc test");
		setClanname("clan");
	}

	public Top100Item(Parcel in) {
		super(in);
	
	}
	
	/**
	 * @return the m_imgSrc
	 */
	public String getImgSrc() {
		return imgSrc;
	}

	/**
	 * @param m_imgSrc the m_imgSrc to set
	 */
	public void setImgSrc(String m_imgSrc) {
		this.imgSrc = m_imgSrc;
	}

	@Override
	public void writeToParcel(Parcel out, int flags) {
		out.writeInt(this.pos);
		out.writeString(this.nickname);
		out.writeInt(this.progress);
		out.writeInt(this.classtime);
		out.writeString(this.clanname);
		out.writeString(imgSrc);
	}
	@Override
	public void readFromParcel(Parcel in) {
		setPos(in.readInt());
		setNickname(in.readString());
		setProgress(in.readInt());
		setClasstime(in.readInt());
		setClanname(in.readString());
		setImgSrc(in.readString());
	}

	public static final Parcelable.Creator<Top100Item> CREATOR = new Parcelable.Creator<Top100Item>() {
		public Top100Item createFromParcel(Parcel in) {
			return new Top100Item(in);
		}

		public Top100Item[] newArray(int size) {
			return new Top100Item[size];
		}
	};
	
	@Override
	public String toString() {
		return String.format("%s", String.format("%s = [%s; %s; %s; %s; %s]", className, getPos(), getNickname(), getProgress(), getClasstime(), getClanname()));
	}

	/**
	 * @return the pos
	 */
	public int getPos() {
		return pos;
	}

	/**
	 * @param pos the pos to set
	 */
	public void setPos(int pos) {
		this.pos = pos;
	}

	/**
	 * @return the progress
	 */
	public int getProgress() {
		return progress;
	}

	/**
	 * @param progress the progress to set
	 */
	public void setProgress(int progress) {
		this.progress = progress;
	}

	/**
	 * @return the nickname
	 */
	public String getNickname() {
		return nickname;
	}

	/**
	 * @param nickname the nickname to set
	 */
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	/**
	 * @return the classtime
	 */
	public int getClasstime() {
		return classtime;
	}

	/**
	 * @param classtime the classtime to set
	 */
	public void setClasstime(int classtime) {
		this.classtime = classtime;
	}

	public static String convertClassToString(int cls){
		if(cls == Top100Item.ASSAULT_CLASS_TYPE){
			return AppManager.getContext().getString(R.string.assault_class);
		}
		else if(cls == Top100Item.ENGINEER_CLASS_TYPE){
			return AppManager.getContext().getString(R.string.engineer_class);
		}
		else if(cls == Top100Item.MEDIC_CLASS_TYPE){
			return AppManager.getContext().getString(R.string.medic_class);
		}
		else if(cls == Top100Item.SNIPER_CLASS_TYPE){
			return AppManager.getContext().getString(R.string.sniper_class);
		}
		return "unknown";
	}
	
	public String getPreviewStr(){
		return String.format("%s_%s", Top100Item.class.getName().replace(Top100Item.class.getPackage().getName() , ""), getNickname());
	}

	public String getClanname() {
		return clanname;
	}

	public void setClanname(String clanname) {
		this.clanname = clanname;
	}
}